Airpodder.data.Channel = Ext.data.Record.create([
  {name: 'id',                    type: 'string', unique: true},
  {name: 'url',                   type: 'string'},
  {name: 'title',                 type: 'string'},
  {name: 'override_title',        type: 'string'},
  {name: 'link',                  type: 'string'},
  {name: 'description',           type: 'string'},
  {name: 'image',                 type: 'string'},
  {name: 'pubDate',               type: 'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''},
  {name: 'sync_to_devices',       type: 'boolean'},
  {name: 'device_playlist_name',  type: 'string'},
  {name: 'username',              type: 'string'},
  {name: 'password',              type: 'string'},
  {name: 'last_modified',         type: 'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''},
  {name: 'etag',                  type: 'string'},
  {name: 'deleted',               type: 'boolean'},
  {name: 'channel_is_locked',     type: 'boolean'},
  {name: 'foldername',            type: 'string'},
  {name: 'auto_foldername',       type: 'boolean'}
]);

Airpodder.data.Episode = Ext.data.Record.create([
  {name: 'id',          type: 'string', unique: true},
  {name: 'channel_id',  type: 'string'},
  {name: 'url',         type: 'string'},
  {name: 'title',       type: 'string'},
  {name: 'length',      type: 'int'},
  {name: 'mimetype',    type: 'string'},
  {name: 'guid',        type: 'string'},
  {name: 'description', type: 'string'},
  {name: 'link',        type: 'string'},
  {name: 'pubDate',     type: 'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''},
  {name: 'state',       type: 'boolean'},
  {name: 'locked',      type: 'boolean'},
  {name: 'filename',    type: 'string'},
  {name: 'played',      type: 'boolean'}
]);

Airpodder.data.Downloader = Ext.data.Record.create([
  {name: 'id',        type: 'string', unique: true},
  {name: 'episode',   type: 'string'},
  {name: 'progress',  type: 'int'},
  {name: 'size',      type: 'float'},
  {name: 'speed',     type: 'float'},
  {name: 'status',    type: 'string'}
]);

/// Grab a SQL connection instance
Airpodder.data.conn = Ext.sql.Connection.getInstance();

Airpodder.data.channels    = new Airpodder.data.ChannelStore();
Airpodder.data.episodes    = new Airpodder.data.EpisodeStore();
Airpodder.util.feed_parser = new Airpodder.util.FeedParser();
Airpodder.util.downloader  = new Airpodder.util.Downloader();

Airpodder.data.channels.relayEvents(Airpodder.util.feed_parser,   ['feedloaded']);
Airpodder.data.episodes.relayEvents(Airpodder.data.channels,      ['channelupdated']);
Airpodder.util.downloader.relayEvents(Airpodder.util.feed_parser, ['feedloaded']);
